﻿using System;
using System.Collections.Generic;
using WAD.WEB.AppCode;
using WAD.Model;
using WAD.DAL;

namespace QD.Weijie.Web.Passport
{
    public partial class Index : PassportBase
    {
        protected object count;
        protected string groupname, date, endtime;
        protected string kf_sitename, kf_number, kf_phone, kf_email, kf_qq;
        protected void Page_Load(object sender, EventArgs e)
        {
            SetAgent("");
            Dictionary<string, object> model = DaoUser.GetDetail(user_id, "name,nick_name,discount,date");
            if (model != null)
            {
                SetValue("name", Server.UrlEncode(model["name"].ToString()));
                site_name = model["nick_name"].ToString();
                date = Convert.ToDateTime(model["date"]).ToString("yyyy-MM-dd");
                endtime = date;
                count = DAO.ExecuteScalar(string.Format("select count(1) from {0}.dbo.[shared] where id={1} and state=1", DAO.DBName, user_id));

                ////返利折扣
                //if (model["discount"] != DBNull.Value)
                //    SetValues("fc", "daili", "1");
                ////运营者
                //if (model["yunying_agentid"] == DBNull.Value)
                //    SetValues("fc", "yunying", "1");
            }
            Dictionary<string, object> version = DaoUserVersion.GetByUserId(user_id);
            if (version != null)
            {
                endtime = Convert.ToDateTime(version["end_date"]).ToString("yyyy-MM-dd");
                groupname = GetVersion(Convert.ToInt32(version["version_id"]));
            }

            //代理商
            Dictionary<string, object> agent = WAD.DAL.Union.DAOAgent.Get(user_id);
            if (agent != null)
            {
                groupname = "代理商";
                site_name = Convert.ToString(agent["sitename"]);
                if (agent["addtime"]!=DBNull.Value)
                date = Convert.ToDateTime(agent["addtime"]).ToString("yyyy-MM-dd");
                if (agent["endtime"] != DBNull.Value)
                    endtime = Convert.ToDateTime(agent["endtime"]).ToString("yyyy-MM-dd");
                SetAgent(user_id.ToString());
            }
        }
    }
}